

#include "timeElapse.h"

#include <vector>

struct camera {
    int m = 0;
    int k = 9;
};

class PIP {
public:

    int process1() {
        sleep(1);
        std::cout << __FUNCTION__ << std::endl;
    }

    int process2() {
        sleep(2);
        m_ret.push_back(55);
        std::cout << __FUNCTION__ << std::endl;
    }

    int process3(camera &cam) {
        sleep(1);
        m_ret.push_back(88);
        std::cout << __FUNCTION__ << "  " << cam.k << std::endl;
        cam.k = 108;
    }

public:
    bool ISSizeB1() {
        return (m_ret.size() > 0);
    }

    bool ISSizeB2() {
        return (m_ret.size() > 1);
    }

    std::vector<int> m_ret;
    float m_avgTime1 = 0.0;
    float m_avgTime2 = 0.0;
    float m_avgTime3 = 0.0;
};


int main() {

    PIP pip;
    camera cam;
    cam.m = 76;
    while (true) {


        timeElapse::timeElaspse(boost::bind(&PIP::process1, &pip),
                                boost::bind(&PIP::ISSizeB1, &pip), pip.m_avgTime1, "PROCESS1");

        timeElapse::timeElaspse(boost::bind(&PIP::process2, &pip),
                                boost::bind(&PIP::ISSizeB1, &pip), pip.m_avgTime2, "PROCESS2");

        timeElapse::timeElaspse(boost::bind(&PIP::process3, &pip, cam),
                                true, pip.m_avgTime3, "PROCESS3");

        timeElapse::timeElaspse(boost::bind(&PIP::process3, &pip, cam),
                                true);


        pip.m_ret.clear();
    }

}